<?php
include_once("./_common.php");

header("Content-charset=$g4[charset]");
header('Content-Type: application/vnd.ms-excel');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Disposition: attachment; filename="' . date("ymd", time()) . '.xls"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');

$eb1 = $_GET['eb1'];
$eb2 = $_GET['eb2'];

// if($eb1 == "all" && $eb2 == "all") {
// 	$sql = "select * from visit_record order by id DESC";
// } else if ($eb1 == "all" && $eb2 != "all") {
// 	$sql = "select * from visit_record where vi_name1 = '$eb2' order by id DESC";
// } else if ($eb1 != "all" && $eb2 == "all") {
// 	$sql = "select * from visit_record where vi_store = '$eb1' order by id DESC";
// } else {
// 	$sql = "select * from visit_record where vi_store = '$eb1' AND vi_name1 = '$eb2' order by id DESC";
// }

$sql = "select * from visit_record ";

if ( $eb1 ){
	$sql .= " where vi_store= '$eb1' ";

}
$sql .= "order by id DESC";


$rst = sql_query($sql);
while($row = mysql_fetch_assoc($rst)) {
	$info[] = $row;
}
?>
<html>
<head>
<title>방문일지 관리</title>
<style>
.txt {mso-number-format:'\\@';}
th {text-align:left;background-color:#f4f4f4}
</style>
</head>
<body>
<table border='1' width='1200'>
<tr bgcolor="#eeeeee">
<td align="center" style="font-weight:bold">방문일자</td>
<td align="center" style="font-weight:bold">구분</td>
<td align="center" style="font-weight:bold">방문자</td>
<td align="center" style="font-weight:bold">점명</td>
<td align="center" style="font-weight:bold">점주명</td>
</tr>
<?php
for($i = 0; $i < count($info); $i += 1) { ?>
<tr>
<td align="center"><?php echo $info[$i]['vi_date']?></td>
<td align="center"><?php echo $info[$i]['vi_flag']?></td>
<td align="center"><?php echo $info[$i]['vi_name1']?></td>
<td align="center"><?php echo $info[$i]['vi_store']?></td>
<td align="center"><?php echo $info[$i]['vi_name2']?></td>
</tr>
<? } ?>
</table>